package com.lagou.filter;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @ClassName JedisPool
 * @Description TODO
 * @Auth ying.xiao
 * @Date 2021/4/13
 * @Version 1.0.0
 */
public class JedisPoolUtil {

    private static JedisPool pool;

    static {

        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(20);
        config.setMaxIdle(10);
        config.setMinIdle(2);

        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);

        config.setBlockWhenExhausted(true);

        pool = new JedisPool(config,"127.0.0.1",6379,1000*2);
    }

    public static Jedis getJedis(){
        return  pool.getResource();
    }
}
